<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/list.css">
</head>
<body>
<div class="list">
	<!-- Container -->
	<div id="container">
		<div class="shell">
			<!-- Main -->
			<div id="main">
				<div class="cl">&nbsp;</div>
				
				<!-- Content -->
				<div id="content">
					
					<!-- Box -->
					<div class="box menu">
						<!-- Box Head -->
						<div class="box-head">
							<h2 class="left">数据列表</h2>
						</div>
						<!-- End Box Head -->	

						<!-- Table -->
						<div class="table">
							<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<th width="13"><input type="checkbox" class="checkbox" /></th>
									<th>回复</th>
									<th class="response">响应</th>
									<th>操作</th>
								</tr>
								<foreach name="list" item="vo">
									<tr class="row">
										<td><input type="checkbox" class="checkbox" /></td>
										<td><h3><a href="#">{$vo['reply']}</a></h3></td>
										<td class="rem"><p>{$vo['response']}</p></td>
										<td>
											<a href="###" class="ico del"  onclick="if(confirm('确定删除吗 ?')){deletes({$vo['id']},this)}">删除</a><a href="###" class="ico edit" _reply="{$vo['reply']}"
											_response="{$vo['response']}" _id="{$vo['id']}">编辑</a>
										</td>
									</tr>
								</foreach>
							</table>				
							<!-- Pagging -->
							<div class="pagging">
								<div class="left"><a href="###">添加</a><span class="reminder">{$reminder}</span></div>
								<div class="right">{$page}
								</div>
							</div>
							<!-- End Pagging -->
						</div>
						<!-- Table -->
						
					</div>
					<!-- End Box -->
					<div class="box edit-1">
						<!-- Box Head -->
						<div class="box-head">
							<h2 class="left">编辑数据</h2>
						</div>
						<!-- End Box Head -->
						<div class="syrian-main-page">
	                        <form action="{:U('index/updates')}" method="post">
	                            <div class="form-group-1">
	                                <span class="col-sm-1">回复:</span>
	                                    <input type="text" class="reply-control contro-reply" name="reply" value="">
	                            </div>
                                <div class="form-group-2">
	                                <span class="col-sm-11">响应:</span>&nbsp;&nbsp;&nbsp;
	                                <textarea class="response-control edit-control" name="response" _id=""></textarea>
                           	 	</div>
	                            <div class="col-sm-11">
	                                <button type="button" class="btn btn-submit edit-submit">提交</button>
	                                <button type="button" class="btn btn-cancel">取消</button>
	                            </div>
							</form>
						</div>
					<!-- End Box -->
					</div>
					<div class="box add">
						<!-- Box Head -->
						<div class="box-head">
							<h2 class="left">添加数据</h2>
						</div>
						<!-- End Box Head -->
						<div class="syrian-main-page">
	                        <form action="{:U('reply/inserts')}" method="post">
	                            <div class="form-group-1">
	                                <span class="col-sm-1">回复:</span>
	                                    <input type="text" class="reply-control contro-reply" placeholder="请输入回复内容"  name="reply">
	                            </div>
                                <div class="form-group-2">
	                                <span class="col-sm-11">响应:</span>&nbsp;&nbsp;&nbsp;
	                                <textarea class="response-control" name="response" placeholder="请输入响应内容"></textarea>
                           	 	</div>
	                            <div class="col-sm-11">
	                                <button type="submit" class="btn btn-submit">提交</button>
	                                <button type="button" class="btn btn-cancel">取消</button>
	                            </div>
							</form>
						</div>
					<!-- End Box -->
					</div>

				<!-- End Content -->
				</div>
				<div class="cl">&nbsp;</div>			
			</div>
			<!-- Main -->
		</div>
	</div>
	<!-- End Container -->
</div>
<script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
<script type="text/javascript">
	function deletes(id,that){
		$.ajax({
			type:"post",
			async:true,
			url: "{:U('reply/deletes')}",
			data:{id:id},
		    success: function(){
			 	$(that).parents('.row').remove();
			}
		});
	}
		
	var aEdit         = $(".table .edit");
	var oInput        = $(".edit-1 input.reply-control");
	var oTextarea     = $(".edit-1 textarea.edit-control");
	var oList         = $("#container #content div.menu");
	var oUpdate       = $("#content .edit-1");
	var oSubmit       = $("#content .edit-submit");

	for( i = 0; i <= aEdit.length; i++ ){
		(function(i){
			$(aEdit[i]).bind('click',function(){
				var uId  = $(this).attr("_id");
				
				$(oList).fadeOut('normal');
				$(oUpdate).fadeIn(1500);
				
				$(oTextarea).attr("_id", uId);
				var uReply     = $(this).attr('_reply');
				var uResponse  = $(this).attr('_response');

				$(oInput).attr({value: uReply});
				$(oTextarea).html(uResponse);

			});
		})(i);
	}
	$(oSubmit).bind('click',function(){	
		if(confirm('确定要修改吗？')){
			var aResponse  = $(oTextarea).val();
			var aReply     = $(oInput).val();
			var aId        = $(oTextarea).attr("_id");

			$.ajax({
				type:"post",
				async:true,
				url: "{:U('reply/updates')}",
				data:{id:aId,reply:aReply,response:aResponse},
				success:function(){
					location.href = "";
				}
			});
		}
	});
</script>
<script type="text/javascript" src="__PUBLIC__/js/index.js"></script>
</body>
</html>